package com.qf.dao;

import com.qf.bean.Student;
import com.qf.sql.StudentSql;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@CacheNamespace(size = 200)
public interface StudentDao {

    @Insert("insert into student(sname2,sex,password) value(#{sname1},#{sex},#{password})")
    @Options(useGeneratedKeys = true,keyProperty = "sid")
    public int insertStudent(Student student);
    @Update("update student set sname2=#{sname1},sex=#{sex} where sid=#{sid}")
    public int updateStudent(Student student);
    @Delete("delete from student where sid=#{sid}")
    public int deleteStudent(int sid);
   /* @Select("select * from student")
    @Results({
            @Result(column = "sname2",property = "sname1")
    })*/
   @SelectProvider(type = StudentSql.class,method = "select")
    public List<Student>  findall();
   //动态查询
    @SelectProvider(type = StudentSql.class,method = "selectbyname")
    @ResultMap("com.qf.dao.StudentDao.a1")
    @Options(useCache = true)
    public List<Student> findbynameAndPassword(Map map);

    //查询学生信息
    @Select("select * from student s,grade g where s.gid=g.cid")
    @ResultMap("com.qf.dao.StudentDao.b1")
    public List<Student> findallstudent();
}
